package cn.ittaoli.ajax.service.impl;

import cn.ittaoli.ajax.dao.SlideMapper;
import cn.ittaoli.ajax.model.Slide;
import cn.ittaoli.ajax.service.SlideService;
import cn.ittaoli.ajax.utils.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.List;

/**
 * Created by lub_lenovo on 2017/8/8.
 */
@Service
public class SlideServiceImpl implements SlideService {
    @Autowired
    private SlideMapper slideMapper;
    public List<Slide> getAll() {
        return slideMapper.getAll();
    }

    public int inserSlide(Slide slide) {
        return slideMapper.insert(slide);
    }

    public PageInfo<Slide> getByPage(Integer pageNum, Integer numPerPage) {
        PageHelper.startPage(pageNum,numPerPage);
        List<Slide> slides=slideMapper.getAll();
        PageInfo<Slide> pageInfo=new PageInfo<Slide>(slides);
        return pageInfo;
    }

//    public Page<Slide> getByPage(Page<Slide> p) {
////        List<Slide> slides=slideMapper.findByPage(p.getStart(),p.getNumPerPage());
//
//
//        PageHelper.startPage(1,3);
//        List<Slide> slides=slideMapper.getAll();
//
//        PageInfo<Slide> pageInfo=new PageInfo<Slide>(slides);
//        p.setTotal(pageInfo.getSize());
//        return p;
//
//    }

}
